<template>
  <div>
    <vue-neditor-wrap v-model="content" :config="myConfig" :destroy="false" @ready="ready"></vue-neditor-wrap>
  </div>
</template>
<script>
import VueNeditorWrap from "vue-neditor-wrap";
export default {
  name: "NeditorCom",
  components: {
    VueNeditorWrap
  },
  props: {
    text: String
  },
  data() {
    return {
      myConfig: {
        // 如果需要上传功能,找后端小伙伴要服务器接口地址 res = {code=200,name="文件名称",url="/img/文件名称.jpg"}
        serverUrl: "/Upload/Single",
        // 你的UEditor资源存放的路径,相对于打包后的index.html
        UEDITOR_HOME_URL: "/NEditor/",
        // 编辑器不自动被内容撑高
        autoHeightEnabled: false,
        // 初始容器高度
        initialFrameHeight: 500,
        // 初始容器宽度
        initialFrameWidth: "100%",
        // 关闭自动保存
        enableAutoSave: false
      },
      content: this.text
    };
  },
  watch: {
    text(newV) {
      this.content = newV ? newV : "";
    },
    content(newV) {
      this.$emit("update:text", newV);
    }
  },
  mounted() {},
  methods: {
    ready(obj) {
      console.log("editor-ready>>", obj);
    }
  }
};
</script>